package test.designpattern.dynamicProxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class RunnerInvocationHandler<T> implements InvocationHandler {
    private T target;

    public RunnerInvocationHandler(T target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        TimeMonitor.start();
        Object result = method.invoke(target, args);
        TimeMonitor.finished(method.getName());
        return result;
    }
}
